package com.shop.controller;

import com.shop.result.JsonResult;
import com.shop.service.GoodsCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/goodsCollection")
public class GoodsCollectionController {
    @Autowired
    private GoodsCollectionService goodsCollectionService;

    @RequestMapping("/getCollectionByCondition")
    @ResponseBody
    public JsonResult getCollectionByCondition(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsCollectionService.getUserCollectionByCondition(request,response);
        return result;
    }

    @RequestMapping("/addCollectionByUser")
    @ResponseBody
    public JsonResult addCollectionByUser(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsCollectionService.addUserCollection(request,response);
        return result;
    }

    @RequestMapping("/deleteCollection")
    @ResponseBody
    public JsonResult deleteCollection(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsCollectionService.deleteUserCollection(request,response);
        return result;
    }

}
